package com.briup.shopadmin.web.controller;

import com.briup.shopadmin.common.Result;
import com.briup.shopadmin.service.IFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("file")
@Api(tags = "文件管理相关接口")
public class FileController {

    @Autowired
    IFileService fileService;

    @ApiOperation("文件上传至图片服务器")
    @PostMapping
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query",dataType = "String",allowableValues = "users,banners,goods",required = true,value = "根据上传的图片所属业务选择对 应的query参数只能是banners或 者users或者goods")

    }
    )
    public Result  upload(String query, MultipartFile multipartFile){

        String imgName = fileService.upload(query, multipartFile);
        return  Result.success(imgName);
    }

}
